﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace LSW.Wcf.App
{
    public sealed class DbParameter
    {
        private IDataParameter mParameter;

        public DbParameter()
        {
            this.mParameter = new SqlParameter();   
        }

        public DbParameter(string parameterName, SqlDbType dbType)
        {
            this.mParameter = new SqlParameter(parameterName, dbType);   
        }

        public DbParameter(string parameterName, object parameterValue)
        {
            
            this.mParameter = new SqlParameter(parameterName, parameterValue);
        }

        public DbParameter(string parameterName, SqlDbType dbType, int size)
        {
            this.mParameter = new SqlParameter(parameterName, dbType, size);
        }

        public DbParameter(string parameterName, SqlDbType dbType, int size, string sourceColumn)
        {
                     
           this.mParameter = new SqlParameter(parameterName, dbType, size, sourceColumn); 
        }

        public DbParameter(string parameterName, SqlDbType dbType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string sourceColumn, DataRowVersion sourceVersion, object value)
        {
            this.mParameter = new SqlParameter(parameterName, dbType, size, direction, isNullable, precision, scale, sourceColumn, sourceVersion, value);           
        }

        public SqlDbType DbType
        {
            get
            {
                return (SqlDbType)this.mParameter.DbType;
            }
            set
            {
                ((SqlParameter)this.mParameter).SqlDbType = value;
            }
        }

        public ParameterDirection Direction
        {
            get
            {
                return this.mParameter.Direction;
            }
            set
            {
                this.mParameter.Direction = value;
            }
        }

        public bool IsNullable
        {
            get
            {
                return this.mParameter.IsNullable;
            }
        }

        internal IDataParameter Parameter
        {
            get
            {
                return this.mParameter;
            }
        }

        public string ParameterName
        {
            get
            {
                return this.mParameter.ParameterName;
            }
            set
            {
                this.mParameter.ParameterName = value;
            }
        }

        public string SourceColumn
        {
            get
            {
                return this.mParameter.SourceColumn;
            }
            set
            {
                this.mParameter.SourceColumn = value;
            }
        }

        public DataRowVersion SourceVersion
        {
            get
            {
                return this.mParameter.SourceVersion;
            }
            set
            {
                this.mParameter.SourceVersion = value;
            }
        }

        public object Value
        {
            get
            {
                return this.mParameter.Value;
            }
            set
            {
                this.mParameter.Value = value;
            }
        }
    }
}